#ifndef LOGGER_H_
#define LOGGER_H_

#include "Logger/LogLogger.h"


/// Define log macro if logging is enabled. Else do nothing with params to avoid unused variable error.
#ifdef MV_LOG_ENABLED

/**
 * Common implementation for sending entries to the log.
 *
 * @param level The log level to associate with the log line.
 * @param entry The text (or builder of the text) for the log entry.
 */
#define MV_LOG(level, entry)                                    \
    do {                                                        \
        auto loggerInstance = logger::MV_GET_LOGGER_FUNCTION(); \
        loggerInstance->log(level, entry);                      \
    } while (false)
#else

#define MV_LOG(level, entry)        \
    do {                            \
        (void)level;                \
        (void)entry;                \
    } while (false)

#endif

/*
 * Set Level for logger.
 *
 * @param level The lowest severity level to be output by this logger.
 */
#define MV_SETLOGLEV(level)   logger::MV_GET_LOGGER_FUNCTION()->setLevel(level)


/// Define debug log macro if logging of debug is enabled.
#ifdef MV_DEBUG_LOG_ENABLED

#define MV_DEFAULT_LOG_LEVEL logger::Level::DEBUG2

/**
 * Send a DEBUGX severity log line.
 *
 * @param loggerArg The Logger to send the line to.
 * @param entry The text (or builder of the text) for the log entry.
 */
#define MV_DEBUG2(entry) MV_LOG(logger::Level::DEBUG2, entry)

#define MV_DEBUG1(entry) MV_LOG(logger::Level::DEBUG1, entry)

#define MV_DEBUG0(entry) MV_LOG(logger::Level::DEBUG0, entry)

#define MV_DEBUG(entry) MV_LOG(logger::Level::DEBUG0, entry)

#else  // MV_DEBUG_LOG_ENABLED

#define MV_DEFAULT_LOG_LEVEL logger::Level::INFO

/**
 * Compile out a DEBUG severity log line.
 */
#define MV_DEBUG2(entry)

#define MV_DEBUG1(entry)

#define MV_DEBUG0(entry)

#define MV_DEBUG(entry)

#endif  // MV_DEBUG_LOG_ENABLED

/**
 * Send a INFO severity log line.
 */
#define MV_INFO(entry) MV_LOG(logger::Level::INFO, entry)

/**
 * Send a WARN severity log line.
 */
#define MV_WARN(entry) MV_LOG(logger::Level::WARN, entry)

/**
 * Send a ERROR severity log line.
 */
#define MV_ERR(entry) MV_LOG(logger::Level::ERROR, entry)

/**
 * Send a CRITICAL severity log line.
 */
#define MV_CRI(entry) MV_LOG(logger::Level::CRITICAL, entry)

#endif // LOGGER_H_
